feat: error-context helper, DB pool startup log, last-page cursor test, indexer retry docs#322
Merged
Chucks1093 merged 2 commits intoMay 28, 2026
Conversation
…t, indexer retry docs - Add buildErrorContext() to extract a consistent, log-safe error context (name, message, normalized code, optional debug-only stack, requestId) from any caught value; use it in the global error middleware's structured log (accesslayerorg#302). - Log the database connection-pool configuration (pool size, pool/connect timeouts, query timeout) at startup before accepting requests, parsed from DATABASE_URL with no credentials leaked (accesslayerorg#298). - Add an integration test for the creator list cursor advancing to a partial last page: only the remaining item is returned and hasMore=false (accesslayerorg#301). - Document the indexer retry policy, exponential backoff with jitter, and DLQ exhaustion behavior in docs/indexer/RETRY_BACKOFF.md (accesslayerorg#297). Closes accesslayerorg#297 Closes accesslayerorg#298 Closes accesslayerorg#301 Closes accesslayerorg#302
|
@tosin-zoffun Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
…t startup Replace the ad-hoc console.error in the global error handler with a structured log built via buildErrorContext (request id + normalized code, stack only in development) (accesslayerorg#302), and log the database connection pool configuration once at startup so connection exhaustion is diagnosable (accesslayerorg#298). Closes accesslayerorg#302 Closes accesslayerorg#298
|
Follow-up: wired the two helpers into the live code paths so they're actually exercised (the first commit only added them):
Verified: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Four small, independent improvements.
#302 — Structured error context helper
Adds
buildErrorContext(err, options)insrc/utils/error-context.utils.ts: produces a consistent{ name, message, code, requestId?, stack?, timestamp }from any caught value (Error subclasses, PrismaP*errors, Zod/JWT by name, plain strings). The error code is normalized to the sharedErrorCodevalues, and thestackis debug-only (omitted unlessincludeStack). Applied in the global error middleware's structured log so the request id and normalized code are logged together.#298 — Startup log for DB connection pool config
describeDatabasePoolConfig()parsesDATABASE_URLfor the pool settings Prisma reads (connection_limit,pool_timeout,connect_timeout) plus the query-timeout, andserver.tslogs them right afterprisma.$connect()— before the server accepts requests. No credentials or host details are included (parsing failures degrade to'default').#301 — Integration test: cursor → partial last page
The existing cursor round-trip test covers an even split (6 items / two full pages). This adds
creator-list-last-page.integration.test.tsfor the end-of-list edge: a known total of 5 atlimit=2yields pages[2, 2, 1]; the last page returns only the remaining item andmeta.hasMore=false. A second test walks every page and asserts the traversal reconstructs the full set exactly once.#297 — Indexer retry/backoff docs (docs-only)
Adds
docs/indexer/RETRY_BACKOFF.md: documents the exponential backoff with jitter (getBackoffWithJitter: base 1000ms, ×2^attempt, cap 30000ms, jittered byINDEXER_JITTER_FACTOR), the controlling config values, and the DLQ exhaustion behavior (moveToDLQ→indexerDLQ, observable viagetDLQDepth/syncDLQMetrics; the risk of silent loss when the DLQ is disabled).Test plan
tsc --noEmit— 0 errors (afterprisma generate).error-context.utils.test.ts(6),db-pool-config.utils.test.ts(4),creator-list-last-page.integration.test.ts(2).prettier --check+eslintclean on changed files (also enforced by the lint-staged pre-commit hook).Notes / out of scope
jestrun has 17 pre-existing failed suites / 8 failed tests onmain(unrelated files, e.g.activity.service.test.ts) — confirmed identical with this change stashed; this PR introduces zero new failures. Integration tests requireprisma generatefirst.Closes #297
Closes #298
Closes #301
Closes #302